#include "comm.hpp"

int main()
{
    int shmid=GetShm();//获取标识符
    char*shmaddr=(char*)shmat(shmid,nullptr,0);//获取虚拟地址

    int fd=open(FIFO_FILE,O_WRONLY);//打开管道
    if(fd<0)
    {
        log(Fatal,"error string: %s, error code: %d",strerror(errno),errno);
        exit(FIFO_OPEN_ERR);
    }
    //IPC code
    while(true)//无限循环进行共享内存通信
    {
        cout<<"please enter@ ";
        fgets(shmaddr,4096,stdin);//输入一行字符串，避免空格分隔符分割数据
        write(fd,"c",1);//通知对方可以读取了
    }
    shmdt(shmaddr);//去关联
    close(fd);
    return 0;
}